package com.online.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.online.entity.Student;
import com.online.mapper.StudentMapper;
import com.online.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    /**
     * 分页查询所有学生
     * @param studentPage
     * @return
     */
    @Override
    public IPage<Student> findAll(Page<Student> studentPage) {
        return studentMapper.findAll(studentPage);
    }

    /**
     * 根据id查询学生
     * @param studentId
     * @return
     */
    @Override
    public Student findById(Integer studentId) {
        return studentMapper.findById(studentId);
    }

    /**
     * 修改学生密码
     * @param student
     * @return
     */
    @Override
    public int updatePwd(Student student) {
        return studentMapper.updatePwd(student);
    }

    /**
     * 更新学生信息
     * @param student
     * @return
     */
    @Override
    public int update(Student student) {
        return studentMapper.update(student);
    }

    /**
     * 根据ID删除学生
     * @param studentId
     * @return
     */
    @Override
    public int deleteById(Integer studentId) {
        return studentMapper.deleteById(studentId);
    }

    /**
     * 添加学生
     * @param student
     * @return
     */
    @Override
    public int add(Student student) {
        return studentMapper.add(student);
    }
}
